<template>
    <div>
      <button @click="sendDataToParent">发送数据给父组件</button>
      <RecursionField :name="props.name" :schema="props.schema" onlyRenderProperties="true" />
    </div>
  </template>
  
  <script setup lang="ts">
  import { defineProps, defineEmits } from 'vue';
  import { RecursionField } from '@formily/vue';
  
  // 定义接收的 props
  const props = defineProps<{
    name: string;
    schema: any;
  }>();
  
  // 定义要触发的自定义事件
  const emits = defineEmits(['dataFromChild']);
  
  // 触发自定义事件并传递数据
  const sendDataToParent = () => {
    console.log('sendDataToParent 方法被调用'); // 添加调试信息
    const data = '这是子组件传递给父组件的数据';
    emits('dataFromChild', data);
  };
  
  </script>
  
  <style lang='less' scoped></style>